package com.example.cricketscorer.client.view;

import com.example.cricketscorer.client.presenter.ScoringActionsPresenter.IScoringActionsView;
import com.example.cricketscorer.client.widget.impl.MyButton;
import com.example.cricketscorer.client.widget.impl.MyTextBox;
import com.example.cricketscorer.client.widget.interfaces.IButton;
import com.example.cricketscorer.client.widget.interfaces.ITextBox;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class ScoringActionsView extends Composite implements IScoringActionsView {
	
	private MyTextBox score4BallText = new MyTextBox();
	private MyButton zeroButton = new MyButton("0");
	private MyButton oneButton = new MyButton("1");
	private MyButton twoButton = new MyButton("2");
	private MyButton threeButton = new MyButton("3");
	private MyButton fourButton = new MyButton("4");
	private MyButton sixButton = new MyButton("6");
	private MyButton wideButton = new MyButton("WD");
	private MyButton noBallButton = new MyButton("NB");
	private MyButton byeButton = new MyButton("B");
	private MyButton legByeButton = new MyButton("LB");
	private MyButton plusButton = new MyButton("+");
	private MyButton wicketButton = new MyButton("WKT");
	private MyButton confirmButton = new MyButton("OK");
	
	public ScoringActionsView() {
		super();
		
		Grid runsPanel = new Grid(2,3);
		runsPanel.setWidget(0, 0, zeroButton);
		runsPanel.setWidget(0, 1, oneButton);
		runsPanel.setWidget(0, 2, twoButton);
		runsPanel.setWidget(1, 0, threeButton);
		runsPanel.setWidget(1, 1, fourButton);
		runsPanel.setWidget(1, 2, sixButton);

		Grid extrasPanel = new Grid(2,2);		
		extrasPanel.setWidget(0, 0, wideButton);
		extrasPanel.setWidget(0, 1, noBallButton);
		extrasPanel.setWidget(1, 0, byeButton);
		extrasPanel.setWidget(1, 1, legByeButton);
		
		Grid controlPanel = new Grid(2,1);		
		controlPanel.setWidget(0, 0, wicketButton);
		controlPanel.setWidget(1, 0, confirmButton);		
		
		HorizontalPanel buttons = new HorizontalPanel();
		buttons.add(runsPanel);
		buttons.add(extrasPanel);
		buttons.add(controlPanel);
		
		HorizontalPanel displayPanel = new HorizontalPanel();
		displayPanel.add(score4BallText);
		displayPanel.add(plusButton);
		
		VerticalPanel container = new VerticalPanel();
		container.add(displayPanel);
		container.add(buttons);
		
		initWidget(container);
	}

	@Override
	public Widget getMyWidget() {
		return this;
	}

	@Override
	public ITextBox getScore4BallText() {
		return score4BallText;
	}

	@Override
	public IButton getZeroButton() {
		return zeroButton;
	}

	@Override
	public IButton getOneButton() {
		return oneButton;
	}

	@Override
	public IButton getTwoButton() {
		return twoButton;
	}

	@Override
	public IButton getThreeButton() {
		return threeButton;
	}

	@Override
	public IButton getFourButton() {
		return fourButton;
	}

	@Override
	public IButton getSixButton() {
		return sixButton;
	}

	@Override
	public IButton getWideButton() {
		return wideButton;
	}

	@Override
	public IButton getNoBallButton() {
		return noBallButton;
	}

	@Override
	public IButton getByeButton() {
		return byeButton;
	}

	@Override
	public IButton getLegByeButton() {
		return legByeButton;
	}

	@Override
	public IButton getPlusButton() {		
		return plusButton;
	}

	@Override
	public IButton getWicketButton() {		
		return wicketButton;
	}

	@Override
	public IButton getConfirmButton() {
		return confirmButton;
	}

}
